package cn.donting.jme.expansion.attribute.lmpl;

import cn.donting.jme.expansion.attribute.ValueChangeListener;
import cn.donting.jme.swing.JFloatTextField;

import java.awt.*;
import java.math.BigDecimal;


public class FloatAttribute extends AbsLineAttribute<Float,JFloatTextField> implements ValueChangeListener<BigDecimal> {

//
    public FloatAttribute(String title) {
        super(new JFloatTextField());
        inputComponent.setMaximumSize(new Dimension(100,50));
        setTitle(title);
        inputComponent.addValueChangeListener(this);
    }


    public void setStepSize(float step) {
        inputComponent.setStepSize(new BigDecimal(step + ""));
    }

    public void setMaxValue(float mixValue) {
        inputComponent.setMaxValue(new BigDecimal(mixValue + ""));
    }

    public void setMinValue(float minValue) {
        inputComponent.setMinValue(new BigDecimal(minValue + ""));
    }

    @Override
    public void setValue(Float value) {
        inputComponent.setValue(new BigDecimal(value + ""));
    }

    @Override
    protected Float getInputValue() {
        return inputComponent.getValue().floatValue();

    }


    @Override
    public void change(BigDecimal newValue) {
        valueChange(getValue());
    }
}
